Skip to content

Conversation

@tcp13equals2
Copy link
Contributor

@tcp13equals2 tcp13equals2 commented Dec 31, 2025

What this PR does

Now that MQE supports delayed name removal, it is possible to include the metric name in histogram_quantile() warning and info annotations.

This brings parity to the Prometheus implementation.

The metric names are only included in the relevant warning/info annotations if EnableDelayedNameRemoval is enabled.

Which issue(s) this PR fixes or relates to

Fixes #3299

Checklist

  • [x ] Tests updated.
  • Documentation added.
  • [ x] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]. If changelog entry is not needed, please add the changelog-not-needed label to the PR.
  • about-versioning.md updated with experimental features.

Note

Adds metric names to histogram_quantile warning/info annotations when EnableDelayedNameRemoval is on, aligning with Prometheus behavior.

  • Plumbs delayed name removal into histogram functions; annotations now emit metric name conditionally
  • Refactors tests to run against engines with delayed name removal both enabled/disabled, with dual expected annotations
  • Adds ours/native_histograms_delayed_name_removal_disabled.test and enables related upstream tests; updates optimizer test skips accordingly
  • Updates CHANGELOG.md with enhancement entry

Written by Cursor Bugbot for commit fe279ba. This will update automatically on new commits. Configure here.

@tcp13equals2 tcp13equals2 marked this pull request as ready for review January 2, 2026 00:15
@tcp13equals2 tcp13equals2 requested a review from a team as a code owner January 2, 2026 00:15
Copy link
Contributor

@fionaliao fionaliao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have these test cases been disabled? Weren't they previously passing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TestEliminateDeduplicateAndMergeOptimizationWithDelayedNameRemovalDisabled() test case fails on this upstream file because it runs with delated name removal disabled.

Rather then disable the tests I add another Skip inside this test for the specific file. Note that the tests have been copied into the 2 new "ours" files, so we still get the same test coverage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ours/native_histograms_delayed_name_removal_enabled.test should be identical to upstream/native_histograms.test? If so, do we need the copy in ours?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only copied out the tests relevant to the new files. So the file is not identical.

Since we will uncomment the Unsupported by streaming engine from the upstream file, I'll remove the native_histograms_delayed_name_removal_enabled.test as this will not be needed.

We will just keep the _disabled.test file.

Copy link
Contributor

@tacole02 tacole02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changelog LGTM

data: mixedClassicHistograms,
expr: `histogram_quantile(0.5, series{host="d"})`,
expectedInfoAnnotations: []string{`PromQL info: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) (1:25)`},
expectedInfoAnnotationsDelayedNameRemovalEnabled: []string{`PromQL info: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) for metric name "series" (1:25)`},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realise this isn't something we can control, but I find the expression here hard to follow - the "for metric name ..." bit seems out of place after the parentheses, it fits better before the parentheses to me.

Perhaps something to change upstream?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which ones do you like;

  • The histogram_quantile input for metric "series" was corrected to enforce monotonicity (1:25) - see ....
  • The histogram_quantile input for metric "series" was fixed to enforce monotonicity (1:25) - see ....
  • Corrected non-monotonic histogram_quantile input for metric "series" (1:25) - see ....
  • Fixed non-monotonic histogram_quantile input for metric "series" (1:25) - see ....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with tweaking the old structure:

input to histogram_quantile needed to be fixed for monotonicity for metric name "series" (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So ours/native_histograms_delayed_name_removal_enabled.test should be identical to upstream/native_histograms.test? If so, do we need the copy in ours?

@tcp13equals2
Copy link
Contributor Author

@charleskorn Thanks for your feedback and suggestions. Do you have any other feedback for this PR?

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is ON, but it could not run because the Cursor GitHub App does not have access to this repository. If the app is installed on your organization with "selected repositories", make sure this repository is included in the selection.

data: mixedClassicHistograms,
expr: `histogram_quantile(0.5, series{host="d"})`,
expectedInfoAnnotations: []string{`PromQL info: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) (1:25)`},
expectedInfoAnnotationsDelayedNameRemovalEnabled: []string{`PromQL info: input to histogram_quantile needed to be fixed for monotonicity (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile) for metric name "series" (1:25)`},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK with tweaking the old structure:

input to histogram_quantile needed to be fixed for monotonicity for metric name "series" (see https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile)

@tcp13equals2
Copy link
Contributor Author

@charleskorn The un-necessary test file has been removed and the test string updated. Anything else you can see needs addressing?

Copy link
Contributor

@charleskorn charleskorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo last remaining reference to deleted test file:

@tcp13equals2 tcp13equals2 merged commit bfd7400 into main Jan 20, 2026
39 checks passed
@tcp13equals2 tcp13equals2 deleted the include-metric-name-in-annotations-from-histogram_quantile branch January 20, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants